package com.drink.yan.job;

import com.drink.yan.intf.define.YanActivityStatusE;
import com.drink.yan.intf.entity.YanSchoolAdjust;
import com.drink.yan.intf.entity.YanSchoolRecruit;
import com.drink.yan.intf.vo.ActivityVo;
import com.drink.yan.svc.service.YanActivityService;
import com.drink.yan.svc.service.YanSchoolService;
import com.drink.yan.web.rest.req.qry.PageActivityQry;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 定时任务，计算活动状态
 *
 * @Title:
 * @Package: com.drink.yan.job.
 * @Author: M.simple
 * @Remark: The modified content
 * @CreateDate: 2023-12-18 12:12
 * @Version: v2.0
 */
@Slf4j
@Component("YanSchoolRecruitUserJob")
public class YanSchoolRecruitUserJob {

	@Value("${schdule.job.enable}")
	private Boolean schduleJobEnable;

	@Resource
	private YanSchoolService yanSchoolService;

	public void handle(){

		if(!schduleJobEnable){
			return;
		}

		log.info("===========start YanSchoolRecruitUserJob===========");
		List<YanSchoolRecruit> yanSchoolRecruit = yanSchoolService.calcSchoolRecruitUser();
		yanSchoolRecruit.forEach(x->{
			yanSchoolService.updateRecruitScore(x.getId(), x.getMinScore(), x.getMaxScore(), x.getRecruitUserNumber());
		});

		List<YanSchoolAdjust> yanSchoolAdjust = yanSchoolService.calcSchoolAdjustUser();
		yanSchoolAdjust.forEach(x->{
			yanSchoolService.updateAdjustScore(x);
		});
	}
}
